/*
* TFViewImpl.h
*
* Implements TFViewInterface
*
* Author: Rapid Dojo
* Date: Oct 19, 2007
*/

#include "TFViewInterface.h"
#include "TFMenuView.h"
#include "TFConstants.h"

#include "TFGraphicsManager.h"
#include <vector>
#include <string>

enum PaletteIndexName
{
	EMPTY_SPRITE = 0,
	RED_TROOP = 1,
	BLUE_TROOP = 2,
    RED_FLAG = 3,
    BLUE_FLAG = 4,
	RED_BARRICADE = 5,
	BLUE_BARRICADE = 6,
	BUTTONPAL = 7,
	INACTIVEBUTTON_PAL= 8,
	SELECTED_PAL = 9,
	BTNSELECT_PAL = 10
};

enum TopScreenPaletteIndexName
{
	ACTION_POINTS = 0,
	MOVE_GRID = 1,
	ACTIONPTS_PAL = 2,
	PLACE_PIECE_PAL = 3
};

const int MOVE_GRID_POS_X = 161;
const int MOVE_GRID_POS_Y = 41;

const int ACTIONPTS_POS_X = 51;
const int ACTIONPTS_POS_Y = 41;

const int PLACEPIECE_POS_X = 161;
const int PLACEPIECE_POS_Y = 41;

const int CONFIRMQUIT_YES_X1=49;
const int CONFIRMQUIT_YES_Y1=120;
const int CONFIRMQUIT_YES_X2=109;
const int CONFIRMQUIT_YES_Y2=160;

const int CONFIRMQUIT_NO_X1=150;
const int CONFIRMQUIT_NO_Y1=120;
const int CONFIRMQUIT_NO_X2=209;
const int CONFIRMQUIT_NO_Y2=160;

const int BUTTON_SPRITES_START = 66;


struct PieceSpriteInfo
{
	int pieceType;
	void* spriteName;
	int palIndex;
};

struct PaletteInfo
{
	void* palName;
	PaletteIndexName palType;
};

struct Button
{
    int originX;
    int originY;
	int width;
	int height;
	void* spriteName;
	void* inactiveSpriteName;
    int index;
};

class TFViewImpl: public TFViewInterface
{
public:

	TFViewImpl ();
	virtual ~TFViewImpl ();

    HRESULT BoardClicked(int stylusX, int stylusY, int *row, int *col);
    HRESULT ButtonClicked(int stylusX, int stylusY, int *index);
	void SetModel(TFModelInterface * iTFModel);
	HRESULT Redraw();
	HRESULT DrawPieceLocation(int col, int row, bool isSelected);

	void InitSpriteList();
	void InitTopSpriteList();
	void GameViewInit();
	void UpdateActionPoints(int points);
	void DeInitGame();

	void HideAllSprites();
	void UndoHideSprites();
	void DeselectButton();
	void ShowPlacePieces();
	void HidePlacePieces();
	void SetButtonActive(int index, bool active);
	void HideButton(int index);

private:
	HRESULT DrawCurrentSplash(TF_GAME_MODE gameMode);
	HRESULT DrawCurrentMenu();

	void DrawGameMode();
	void DrawRulesScreen();
	bool GetConfirmQuit();
	void DisplayWinScreen(int player);

	TFMenuView *_menuView;

	PieceSpriteInfo spriteInfo[2][8];//[color,piecetype]
	PaletteInfo palInfo[11];
    std::vector<Button> buttonList;
	int selectedButtonIndex;
	bool gameViewInitiated;

	int selectedSpriteIndex;
	int selectedSpritePalIndex;

	int btnSelectSpriteIndex;
	int btnSelectSpritePalIndex;

	int moveGridSpriteIndex;
	int moveGridPalIndex;

	int numbersSpriteIndex;
	int numbersPalIndex;

	int placePiecesIndex;
	int placePiecesPalIndex;

	//variables for Rules screen
	u16 oldStylusX;
	u16 oldStylusY;

	s32 oldScrollValue;
	s32 howtoScrollValue;

};
